<script setup lang="ts">
import { ref } from "vue";
import { formRules } from "./utils/rule";
import { FormProps } from "./utils/types";

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    pid: null,
    clientName: null,
    clientKey: null,
    tenantId: null,
    grantDate: null,
    endDate: null,
    clientDesc: null,
    archiveStatus: "active",
    editStatus: false
  })
});

const ruleFormRef = ref();
const newFormInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script>

<template>
  <el-form
    ref="ruleFormRef"
    :model="newFormInline"
    :rules="formRules"
    label-width="100px"
  >
    <el-form-item label="客户端名称" prop="clientName">
      <el-input
        v-model="newFormInline.clientName"
        clearable
        placeholder="请输入客户端名称"
      />
    </el-form-item>

    <el-form-item label="授权截止日期" prop="endDate">
      <el-date-picker
        v-model="newFormInline.endDate"
        type="date"
        placeholder="请选择截止日期"
        format="YYYY-MM-DD"
        value-format="YYYY-MM-DD"
        :disabled="false"
      />
    </el-form-item>
    <!-- <el-form-item label="客户端状态" prop="archiveStatus">
      <el-select
        v-model="newFormInline.archiveStatus"
        placeholder="请选择客户端状态"
      >
        <el-option label="启用" value="active" />
        <el-option label="禁用" value="archive" />
      </el-select>
    </el-form-item> -->

    <el-form-item label="备注" prop="clientDesc">
      <el-input
        v-model="newFormInline.clientDesc"
        placeholder="请输入备注信息"
        type="textarea"
      />
    </el-form-item>
  </el-form>
</template>
